﻿using EONFULLSIN.Models.Entity.LanguageData;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EONFULLSIN.Utils
{
    public static class LanguageHelper
    {
        private static LanguageData _languageData;
        public static string CurrentLanguage { get; set; } = "zh";

        static LanguageHelper()
        {
            string json = File.ReadAllText("Languages\\languages.json");
            _languageData = JsonConvert.DeserializeObject<LanguageData>(json);
        }

        public static string GetTranslation(string language, string key)
        {
            if (language == "en" && _languageData.en.ContainsKey(key))
            {
                return _languageData.en[key];
            }
            else if (language == "zh" && _languageData.zh.ContainsKey(key))
            {
                return _languageData.zh[key];
            }
            return key;
        }
    }
}